package dk.pun.dums.shared.user;

import java.io.Serializable;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@SuppressWarnings("serial")
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class UserData implements Serializable {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long key;

	@Persistent
	private String userId;
	@Persistent
	private String nickname;
	@Persistent
	private String email;
	
	@SuppressWarnings("unused")
	private UserData() {}

	public UserData(final String userId) {
		this.userId = userId;
		this.nickname = userId;
	}
	
	public Long getKey() {
		return key;
	}

	public String getUserId() {
		return userId;
	}
	
	public String getNickname() {
		return nickname;
	}

	public void setNickname(final String nickname) {
		this.nickname = nickname;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(final String email) {
		this.email = email;
	}

	@Override
	public boolean equals(final Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final UserData other = (UserData) obj;
		if (key == null) {
			if (other.key != null) {
				return false;
			}
		} else if (!key.equals(other.key)) {
			return false;
		}
		return true;
	}
	
	@Override
	public String toString() {
		return "UserData [userId=" + userId + ", nickname=" + nickname
				+ ", email=" + email + "]";
	}
	
}
